package com.zhentao.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import lombok.Data;

/**
 * 提成明细表，记录每笔提成的详细信息
 * @TableName commission_detail
 */
@TableName(value ="commission_detail")
@Data
public class CommissionDetail implements Serializable {
    /**
     * 主键ID，明细的唯一标识，用于在系统中唯一确定一条提成明细记录
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 提成规则ID，关联提成规则表的ID，表明该笔提成是根据哪个规则计算的
     */
    private Long ruleId;

    /**
     * 销售人员ID，关联销售人员ID，表明该笔提成是属于哪个销售人员的
     */
    private Long salesUserId;

    /**
     * 单据ID，关联业务单据的ID，表明该笔提成是基于哪笔业务产生的
     */
    private Long billId;

    /**
     * 业务金额，该笔业务的发生金额，是计算提成的基础
     */
    private BigDecimal amount;

    /**
     * 提成金额，本次根据业务金额和提成规则计算得出的提成金额
     */
    private BigDecimal commission;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        CommissionDetail other = (CommissionDetail) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getRuleId() == null ? other.getRuleId() == null : this.getRuleId().equals(other.getRuleId()))
            && (this.getSalesUserId() == null ? other.getSalesUserId() == null : this.getSalesUserId().equals(other.getSalesUserId()))
            && (this.getBillId() == null ? other.getBillId() == null : this.getBillId().equals(other.getBillId()))
            && (this.getAmount() == null ? other.getAmount() == null : this.getAmount().equals(other.getAmount()))
            && (this.getCommission() == null ? other.getCommission() == null : this.getCommission().equals(other.getCommission()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getRuleId() == null) ? 0 : getRuleId().hashCode());
        result = prime * result + ((getSalesUserId() == null) ? 0 : getSalesUserId().hashCode());
        result = prime * result + ((getBillId() == null) ? 0 : getBillId().hashCode());
        result = prime * result + ((getAmount() == null) ? 0 : getAmount().hashCode());
        result = prime * result + ((getCommission() == null) ? 0 : getCommission().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", ruleId=").append(ruleId);
        sb.append(", salesUserId=").append(salesUserId);
        sb.append(", billId=").append(billId);
        sb.append(", amount=").append(amount);
        sb.append(", commission=").append(commission);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}